﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntityFrameworkModel;
using System.Transactions;

namespace DifferentDataContexts
{
    class DifferentDataContexts
    {
        static void Main()
        {
            NorthwindEntities context1 = new NorthwindEntities();
            Customer customer1 = context1.Customers.FirstOrDefault(c => c.CustomerID == "A");
            Console.WriteLine("Context1 customer name = {0}", customer1.CompanyName);
            customer1.CompanyName += " Inc.";

            NorthwindEntities context2 = new NorthwindEntities();
            Customer customer2 = context2.Customers.FirstOrDefault(c => c.CustomerID == "A");
            Console.WriteLine("Context2 customer name = {0}", customer2.CompanyName);
            customer2.CompanyName += " Ltd.";

            context1.SaveChanges();
            context2.SaveChanges();

            NorthwindEntities context3 = new NorthwindEntities();
            Customer customer3 = context3.Customers.FirstOrDefault(c => c.CustomerID == "A");
            Console.WriteLine("Context3 customer name = {0}", customer3.CompanyName);
        }
    }
}
